package com.mall.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.dubbo.mapper.SmsCouponHistoryMapper;
import com.mall.model.domain.SmsCouponHistory;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author xyiaao
 * @description 针对表【sms_coupon_history(优惠券使用、领取历史表)】的数据库操作Api实现
 * @createDate 2022-03-29 19:46:09
 */
@DubboService
public class SmsCouponHistoryApiImpl extends ServiceImpl<SmsCouponHistoryMapper, SmsCouponHistory>
        implements SmsCouponHistoryApi {

    @Autowired
    private SmsCouponHistoryMapper smsCouponHistoryMapper;

    @Override
    public Page<SmsCouponHistory> listPage(Integer pageNum, Integer pageSize, Long couponId, String orderSn, Integer useStatus) {

        LambdaQueryWrapper<SmsCouponHistory> lqw = new LambdaQueryWrapper<>();
        lqw.like(StringUtils.isNotEmpty(orderSn), SmsCouponHistory::getOrderSn, orderSn);
        lqw.eq(couponId != null, SmsCouponHistory::getCouponId, couponId);
        lqw.eq(useStatus != null, SmsCouponHistory::getUseStatus, useStatus);

        Page<SmsCouponHistory> page = new Page<>(pageNum, pageSize);

        return smsCouponHistoryMapper.selectPage(page, lqw);
    }

}




